package ch.bfh.abcmmh.tests;

import static org.junit.Assert.*;
import junit.framework.Assert;

import org.apache.log4j.Logger;
import org.junit.Test;

import ch.bfh.abcmmh.controller.logging.TSLoggingFactory;
import ch.bfh.abcmmh.controller.operating.scanner.StreetScanner;
import ch.bfh.abcmmh.model.street.Street;

public class StreetScannerTester {

	@Test
	public void distanceTOTherCar() {
		
		Logger logger = TSLoggingFactory.getConsoleLogger();
		Street street = new Street(100);
		street.setSAttributeVehicle(3);
		for (int i = 0; i < 10; i++) {
			assertTrue(street.getSAttribute(4+i).isFree());
		}
		street.setSAttributeVehicle(14);
		StreetScanner streetScanner = new StreetScanner(street);
		logger.debug(streetScanner.getDistObstacleAhead(3));
		Assert.assertEquals(10, streetScanner.getDistObstacleAhead(3));
		logger.debug(streetScanner.getDistObstacleAhead(13));
		Assert.assertEquals(0, streetScanner.getDistObstacleAhead(13));
		logger.debug(streetScanner.getDistObstacleAhead(8));
		Assert.assertEquals(5, streetScanner.getDistObstacleAhead(8));
		logger.debug(streetScanner.getDistObstacleAhead(20));
		Assert.assertEquals(200, streetScanner.getDistObstacleAhead(20));
	}

}
